<template>
  <div class="user-bar">
    <div class="user-info" v-if="!userinfo">
      <img src="../../assets/user-head-pic.jpg" alt="" />
      <div class="info">
        <div class="name">Hi～欢迎来到广东道道通</div>
        <div class="btn-box">
          <div class="btn login-btn" @click="toLogin">
            <icon name="icondenglu" size="16" />登录
          </div>
          <div class="btn" @click="toLogin(1)">
            <icon name="iconzhuce" size="18" />注册
          </div>
        </div>
      </div>
    </div>
    <div
      class="user-info"
      @click="$router.push({ path: '/user/center' })"
      v-else
    >
      <img :src="userinfo.header_img" alt="" />
      <div class="info">
        <div class="name">{{ userinfo.wechat_name }}</div>
        <div class="btn-box">
          <div class="btn login-btn">
            <icon name="iconzhanghao" size="16" />个人中心
          </div>
        </div>
      </div>
    </div>
    <div class="flex"></div>
    <div class="shortcut">
      <div class="item"><icon name="iconshoucang1" size="30" />我的浏览</div>
      <div class="item"><icon name="iconshoucang1" size="30" />我的收藏</div>
      <div class="item"><icon name="icondingdan" size="30" />我的订单</div>
      <div class="item"><icon name="iconanquan" size="30" />账号安全</div>
      <div class="item"><icon name="iconfenxiang" size="30" />我要分享</div>
      <div class="item">
        <icon name="iconshangjia-dianji" size="30" />商家入口
      </div>
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  name: "UserBar",
  computed: {
    ...mapState("user", ["userinfo"]),
  },
};
</script>

<style lang="scss" scoped>
.user-bar {
  max-width: 1200px;
  margin: -40px auto 0;
  height: 102px;
  background: #ffffff;
  border-radius: 5px;
  display: flex;
  align-items: center;
  position: relative;
  z-index: 6;
  .flex {
    flex: 1;
    text-align: center;
    color: #999999;
    font-size: 16px;
    box-sizing: border-box;
    padding-top: 60px;
    height: 100%;
    font-weight: 600;
  }
  .user-info {
    display: flex;
    padding-left: 23px;
    img {
      width: 70px;
      height: 70px;
      border-radius: 50%;
    }
    .info {
      padding-left: 20px;
      .name {
        font-size: 16px;
        color: #666666;
      }
      .btn-box {
        display: flex;
        margin-top: 16px;
        .btn {
          width: 82px;
          cursor: pointer;
          height: 26px;
          background: #ffffff;
          border-radius: 5px;
          border: 1px solid #d52c1a;
          display: flex;
          font-size: 14px;
          line-height: 14px;
          justify-content: space-evenly;
          align-items: center;
          color: #d52c1a;
          &.login-btn {
            margin-right: 10px;
          }
        }
      }
    }
  }
  .shortcut {
    display: flex;
    color: #333333;
    font-size: 16px;
    .item {
      width: 80px;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      margin-right: 40px;
      cursor: pointer;
      i {
        color: #ff4949;
        margin-bottom: 8px;
      }
      &:hover {
        color: #ff4949;
      }
    }
  }
}
</style>
